# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright (c) 2020 MediaTek
%YAML 1.2
---
$id: http://devicetree.org/schemas/usb/mediatek,musb.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: MediaTek MUSB DRD/OTG Controller

maintainers:
  - Min Guo <min.guo@mediatek.com>

properties:
  $nodename:
    pattern: '^usb@[0-9a-f]+$'

  compatible:
    items:
      - enum:
          - mediatek,mt8516-musb
          - mediatek,mt2701-musb
          - mediatek,mt7623-musb
      - const: mediatek,mtk-musb

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  interrupt-names:
    items:
      - const: mc

  clocks:
    items:
      - description: The main/core clock
      - description: The system bus clock
      - description: The 48Mhz clock

  clock-names:
    items:
      - const: main
      - const: mcu
      - const: univpll

  phys:
    maxItems: 1

  usb-role-switch:
    $ref: /schemas/types.yaml#/definitions/flag
    description: Support role switch. See usb/generic.txt
    type: boolean

  dr_mode:
    enum:
      - host
      - otg
      - peripheral

  power-domains:
    description: A phandle to USB power domain node to control USB's MTCMOS
    maxItems: 1

  connector:
    $ref: /schemas/connector/usb-connector.yaml#
    description: Connector for dual role switch
    type: object

dependencies:
  usb-role-switch: [ 'connector' ]
  connector: [ 'usb-role-switch' ]

required:
  - compatible
  - reg
  - interrupts
  - interrupt-names
  - phys
  - clocks
  - clock-names

additionalProperties: false

examples:
  - |
    #include <dt-bindings/clock/mt2701-clk.h>
    #include <dt-bindings/gpio/gpio.h>
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/interrupt-controller/irq.h>
    #include <dt-bindings/phy/phy.h>
    #include <dt-bindings/power/mt2701-power.h>

    usb@11200000 {
        compatible = "mediatek,mt2701-musb", "mediatek,mtk-musb";
        reg = <0x11200000 0x1000>;
        interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_LOW>;
        interrupt-names = "mc";
        phys = <&u2port2 PHY_TYPE_USB2>;
        dr_mode = "otg";
        clocks = <&pericfg CLK_PERI_USB0>,
                 <&pericfg CLK_PERI_USB0_MCU>,
                 <&pericfg CLK_PERI_USB_SLV>;
        clock-names = "main","mcu","univpll";
        power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
        usb-role-switch;

        connector {
            compatible = "gpio-usb-b-connector", "usb-b-connector";
            type = "micro";
            id-gpios = <&pio 44 GPIO_ACTIVE_HIGH>;
            vbus-supply = <&usb_vbus>;
        };
    };
...
